import axios from 'axios'
import QS from 'qs'
import {http8012} from './devlocalport'
const baseURL = http8012
const instance = axios.create({
    timeout: 5000,
    baseURL,
    headers: {
        'Content-Type': "application/json"
    }
});
instance.interceptors.request.use(
  config => {
    config.headers['Authorization'] = sessionStorage.getItem('token_12')
    return config
  },
  error => {
    return Promise.reject(error)
  }
)
export function post_json(url, params) {
    return new Promise((resolve, reject) => {
        instance.post(url, params)
            .then(res => {
                resolve(res.data);
            })
            .catch(err => {
                reject(err.data)
            })
    });
}
export function get(url, params) {
    return new Promise((resolve, reject) => {
        instance.get(url, {
            params: params
        }).then(res => {
            resolve(res.data);
        }).catch(err => {
            reject(err.data)
        })
    });
}
